home *** CD-ROM | disk | FTP | other *** search
- Path: druid.borland.com!usenet
- From: pete@borland.com (Pete Becker)
- Newsgroups: comp.lang.c++
- Subject: Re: Pure Virtual Destructor Question
- Date: 16 Feb 1996 19:26:48 GMT
- Organization: Borland International
- Message-ID: <4g2lpo$f81@druid.borland.com>
- References: <4fas7a$7ns@comet2.magicnet.net> <4fecq0$k4e@news4.digex.net> <rcauvin-0902960901140001@quadostimpy.natinst.com> <4fp5r2$dm2@news4.digex.net>
- NNTP-Posting-Host: pbecker.borland.com
- Mime-Version: 1.0
- Content-Type: Text/Plain; charset=ISO-8859-1
- X-Newsreader: WinVN 0.99.5
-
- In article <4fp5r2$dm2@news4.digex.net>, ell@access1.digex.net says...
- >
- >Roger L. Cauvin (rcauvin@natinst.com) wrote:
- >: In article <4fecq0$k4e@news4.digex.net>, ell@access4.digex.net (Ell) wrote:
- >:
- >: >It is _illegal_ to logically, or physically "define" a pure
- >: > virtual function in the class it is "declared" in. A pure virtual should
- >: > only be defined in classes derived from the class where the pure virtual
- >: > is declared. Only derived classes should "do some destructor stuff".
- >:
- >: Actually, it is acceptable to define a pure virtual function in the class
- >: in which it is declared. Pure virtual destructors are a special case;
- >: they MUST be defined in the class in which they are declared.
- >
- >Yes, a pure virtual dtor MUST be _defined_ as a member of the class it is
- >declared in. As dtors are not inherited by derived classes, the only
- >place to override the pure virtual declaration for a class is as a member
- >of the class (though it must actually be defined outside of the class
- >declaration).
- >
-
- The issue is not whether you have a place to override it. The issue is whether
- it is actually called.
-
- >Still a class with a single pure virtual declaration, such as a pure
- >virtual dtor declaration is considered to be 'abstract' even with the
- >"outside of class declaration" definition of the pure virtual dtor.
-
- Yes, but this is just a specific example of the general rule that any class
- with a pure virtual function is abstract, even if you provide a definition for
- that function.
-
- void Base
- {
- public:
- virtual void f() = 0;
- };
-
- void Derived : public Base
- {
- public:
- void f() { Base::f(); }
- };
-
- void Base::f()
- {
- }
-
- A definition of Base::f is required because it is called. Base is still an
- abstract class, because it contains a pure virtual function.
- -- Pete
-
-